Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stylehacks

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylehacks

Detect/remove browser hacks from CSS files.

  • 2.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.9M
decreased by-61.47%
Maintainers
1
Weekly downloads
 
Created

What is stylehacks?

The stylehacks npm package is designed to detect and remove hacks from CSS files. These hacks are often used to target specific browsers with CSS rules that wouldn't be valid or necessary in a standards-compliant browser. By identifying and removing these hacks, stylehacks helps in cleaning up CSS files, making them more maintainable and potentially reducing file size.

What are stylehacks's main functionalities?

Detecting CSS hacks

This feature allows the detection and automatic removal of CSS hacks. The code sample demonstrates how to use stylehacks with PostCSS to process a CSS string that contains a hack (`_color: red`), which is targeted at old versions of IE, and remove it.

"const stylehacks = require('stylehacks');
const postcss = require('postcss');

postcss([ stylehacks() ])
.process('h1 { _color: red }', { from: undefined })
.then(result => {
  console.log(result.css);
  // Output will be 'h1 { }' as the hack is removed
});"

Whitelisting specific hacks

This feature allows users to lint for hacks without removing them, useful for cases where a hack is intentionally being used. The code sample shows how to use stylehacks in lint mode, which will not remove the hack but can be used to report or log its presence.

"const stylehacks = require('stylehacks');
const postcss = require('postcss');

postcss([ stylehacks({ lint: true }) ])
.process('h1 { _color: red }', { from: undefined })
.then(result => {
  console.log(result.css);
  // Output will be the same input 'h1 { _color: red }' as it only lints
});"

Other packages similar to stylehacks

Keywords

FAQs

Package last updated on 22 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc